<?php

class AliUtil {

    /**
     * 检查域名是否未注册
     * @param string $domains 多个以,号隔开
     * @return boolean
     */
    public static function checkDomain($domains) {
        $CI = & CI_Controller::get_instance();
        $CI->load->library('HttpUtil');
        $CI->load->service('Service_ip_proxy');
        $CI->load->config('common/domain');
        
        $proxy = $CI->Service_ip_proxy->randProxy();
        $options['proxy'] = $proxy;
        
        $site = $CI->config->item('domain_ali_api');
        $site['url'] .= $domains;
        
        $result = HttpUtil::cfg_request_options($site, $options);
        $info = json_decode($result, true);
        if (!isset($info['module'])) {
            return [];
        }
        
        $res = [];
        foreach ($info['module'] as $item) {
            $res[$item['name']] = $item['avail'];
        }
        return $res;
    }

}
